package com.example.xinguanvue.controller;

import com.example.xinguanvue.bean.User;
import com.example.xinguanvue.service.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/*
用户Controller
 */
@RestController
@RequestMapping("/user")
public class UserController {

    private UserService userService;
    private Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    //分页查询用户数据
    @RequestMapping("/listUser")
    public PageInfo<User> listCourseByCategoryAndPage(@RequestParam(defaultValue = "1") Integer currentPage,
                                                  @RequestParam(defaultValue = "1") Integer pageSize) {
        logger.info("/listCourse 被请求了！");

        logger.info("currentPage:" + currentPage);
        logger.info("pageSize:" + pageSize);
        PageInfo<User> userPageInfo = userService.listCourseByCategoryAndPage(currentPage, pageSize);
        System.out.println(userPageInfo.toString());
        return userPageInfo;
    }


}
